﻿using System;
using System.Net;
using System.Xml.Serialization;
using System.IO.IsolatedStorage;
using System.IO;
using Tulde.Core;

namespace Tulde.MP3tunes
{
    public static class SettingsProvider
    {
        static SettingsProvider()
        {
            Load();
        }
        private static Settings _instance;
        private static string _fileName = "settings.app";
        public static Settings Settings
        {
            get
            {
                return _instance;
            }
        }
        public static void Load()
        {
            try
            {
                var settings = StorageProviderFactory.Instance.Read<Settings>(_fileName);
                if (settings != null)
                {

                    _instance = settings;
                }
                else
                {
                    _instance = new Settings();
                    Save();
                }
            }
            catch
            {
                _instance = new Settings();
                Save();
            }
         
        }
        public static void Save()
        {
            StorageProviderFactory.Instance.Save(_fileName, Settings);
        }
    }
}
